<?php
include "./common.php";
$job = $_GET['job'];

$classid = $_GET['classid'];
$classid && $where = " WHERE classid='$classid'";

if(empty($job)){
	$page = $_GET['page'];
	$pageSize = $_GET['pageSize'];
	!$page && $page =1;
	!$pageSize && $pageSize = 12;

	$limit = " LIMIT ".($page-1)*$pageSize.",$pageSize";

	$query = $db->query("SELECT title,url,classid,hits,id FROM ".tname('image')." $where ORDER BY createtime DESC $limit");
	while($array = $db->fetch_array($query)){
		$rs[] = $array;
	}


	$amount = $db->get_one("SELECT count(*) as amount FROM ".tname('image')." $where ");
	$pages = multi($amount['amount'],$pageSize,$page,"tupian.php?classid=".$classid);

	$query = $db->query("SELECT * FROM ".tname('class'));
	while($array = $db->fetch_array($query)){
		$class[] = $array;
	}


	include template("tupian");
}else if($job=='slide'){
	$query = $db->query("SELECT title,url,classid,hits,id FROM ".tname('image')." $where ORDER BY createtime DESC ");
	while($array = $db->fetch_array($query)){
		$imgurls .= empty($imgurls) ? $array['url'] : "|".$array['url'];
		$titles  .= empty($titles) ? $array['title'] : "|".$array['title'];
//		$rs[] = $array;
	}
	
	include template("tupian_slide");
}
?>